package com.qinggeng.common.enums;

import com.qinggeng.common.exception.CustomException;

public enum PayTypeEnum {

    WXPAY(100,"wxpay","微信支付"),
    ALIPAY(200,"alipay","支付宝支付"),
    FREEPAY(300,"freepay","免费支付"),
    MINIPAY(400,"minipay","小程序支付"),
    ALIPAY_CYCLE(500,"alipay","支付宝周期支付"),
    PAYMENT_ON_BEHALF_OF(600,"minipay","微信代付"),;

    private final Integer value;
    private final String code;
    private final String info;


    PayTypeEnum(Integer value,String code, String info){
        this.value=value;
        this.code = code;
        this.info = info;
    }
    public Integer getValue(){return value;}

    public String getCode()
    {
        return code;
    }

    public String getInfo()
    {
        return info;
    }

    public static PayTypeEnum valuesOf(String code){
        for (PayTypeEnum enums: PayTypeEnum.values()){
            if (enums.getCode().equals(code)){
                return enums;
            }
        }
        return null;
    }

    public static String getPayTypeValue(String code){
        if (code.equals(PayTypeEnum.WXPAY.code)){
            return  WithdrawalTypeEnum.WX.getValue();
        }
        if (code.equals(PayTypeEnum.ALIPAY.code)){
            return  WithdrawalTypeEnum.ALI.getValue();
        }
        if (code.equals(PayTypeEnum.MINIPAY.code)){
            return  WithdrawalTypeEnum.WX.getValue();
        }
        throw  new CustomException("此类型不支持退款");
    }
}
